package controller.api;

/**
 * Created by CHENCO7 on 8/16/2017.
 */

import controller.ClientWebSocketHandler;
import dto.MerchantChangeDto;
import dto.ResponseDto;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class NotifyController {
    @Resource(name="clientWebSocketHandler")
    private ClientWebSocketHandler handler;


    @RequestMapping(value="/api/merchant/status",method=RequestMethod.POST)
    @ResponseBody
    public Object notifyMerchantStatus(@RequestBody MerchantChangeDto merchantChangeDto) {
        ResponseDto responseDto = new ResponseDto();
        responseDto.setCode(1);
        responseDto.setMessage("you have add to " + merchantChangeDto.getStatus());
        responseDto.setData(merchantChangeDto.getStatus());
        handler.notifyCustomer(merchantChangeDto.getStatus());
        ResponseDto res = new ResponseDto(1,"success",null);
        return res;
    }

}
